﻿@page "EntityUi/{moduleName}/{entityName}"
@using EasyAbp.Abp.EntityUi.Web.Pages.EntityUi
@using Volo.Abp.AspNetCore.Mvc.UI.Layout
@model EasyAbp.Abp.EntityUi.Web.Pages.EntityUi.IndexModel
@inject IPageLayout _pageLayout
@{
    _pageLayout.Content.Title = await Model.GetPageTitleAsync();
    _pageLayout.Content.BreadCrumb.Add(await Model.GetBreadCrumbTextAsync());
    _pageLayout.Content.MenuItemName = await Model.GetMenuItemNameAsync();
}

<script type="text/javascript">
    var moduleName = `@Html.Raw(Model.ModuleName)`;
    var localizationResourceName = `@Html.Raw(await Model.GetJsLocalizationResourceNameAsync())`;
    var parentEntityKeysCode = `@Html.Raw(await Model.GetJsParentEntityKeysCodeAsync(false))`;
    var parentEntityKeysCodeForCreateSubEntityModal = `@Html.Raw(await Model.GetJsParentEntityKeysCodeAsync(true, false))`;
    var subEntityListPropertyName = `@Html.Raw(await Model.GetJsSubEntityCollectionPropertyNameAsync())`;
    var findSubEntityIndexCode = `@Html.Raw(await Model.GetJsFindSubEntityIndexCodeAsync("list", "data"))`;
    var serviceCode = `@Html.Raw(await Model.GetJsServiceAsync())`;
    var getListMethodName = `@Html.Raw(await Model.GetJsGetListMethodNameAsync())`;
    var getListInput = @Html.Raw(await Model.GetJsGetListInputCodeAsync());
    var createModalSubPath = `@Html.Raw(await Model.GetJsCreateModalSubPathAsync())`;
    var editModalSubPath = `@Html.Raw(await Model.GetJsEditModalSubPathAsync())`;
    var tableId = '@Html.Raw(await Model.GetTableIdAsync())';
    var editRowActionItemText = '@Html.Raw(await Model.GetJsEditRowActionItemTextAsync())';
    var editEnable = @Html.Raw(Model.Entity.EditEnabled.ToString().ToLower());
    var editPermission = `@Html.Raw(@Model.Entity.EditPermission)`;
    var editKeysCode = `{ @Html.Raw(await Model.GetJsDataTableDataRecordKeysCodeAsync()) }`;
    var deletionEnable = @Html.Raw(Model.Entity.DeletionEnabled.ToString().ToLower());
    var deletionPermission = `@Html.Raw(@Model.Entity.DeletionPermission)`;
    var deletionConfirmMessageReturnCode = `l('@Html.Raw(await Model.GetJsDeletionConfirmMessageTextAsync())', @Html.Raw(await Model.GetJsDataTableDataRecordKeysCodeAsync(false)))`;
    var deletionRowActionItemText = `@Html.Raw(await Model.GetJsDeletionRowActionItemTextAsync())`;
    var deletionActionInputCode = `@Html.Raw(await Model.GetJsDataTableDeletionActionInputAsync())`;
    var successfullyDeletedNotificationText = `@Html.Raw(await Model.GetJsSuccessfullyDeletedNotificationTextAsync())`;
    var newButtonId = `@Html.Raw(await Model.GetNewButtonIdAsync())`;
    var propertyNameTitleMapping = { @Html.Raw(await Model.GetJsDataTablePropertyNameTitleMappingAsync()) };
    var buildSubEntitiesRowActionItemsCode = `@Html.Raw(await Model.GetJsBuildSubEntitiesRowActionItemsAsync())`;
</script>

@section scripts
{
    @if (Model.IsSubEntity)
    {
        <abp-script src="/Pages/EntityUi/index-sub-entity.js" />
    }
    else
    {
        <abp-script src="/Pages/EntityUi/index.js" />
    }
}

<abp-card>
    <abp-card-header>
        <abp-row>
            <abp-column size-md="_6">
                <abp-card-title>@await Model.GetPageTitleAsync()</abp-card-title>
            </abp-column>
            <abp-column size-md="_6" class="text-end">
			    @if (Model.Entity.CreationEnabled && await Model.IsCreationPermissionGrantedOrNullAsync())
                {
                <abp-button id="@await Model.GetNewButtonIdAsync()"
                            text="@await Model.GetNewButtonTextAsync()"
                            icon="plus"
                            button-type="Primary" />
                }
            </abp-column>
        </abp-row>
    </abp-card-header>
    <abp-card-body>
        <abp-table striped-rows="true" id="@await Model.GetTableIdAsync()" class="nowrap"/>
    </abp-card-body>
</abp-card>